﻿@{
    ViewBag.Title = "ChucNang";
    Layout = "~/Views/Shared/Admin/_AdminLayout.cshtml";
}

@using PagedList
@using PagedList.Mvc
<div style="background: #fff; text-align: right; height: 60px; width: 100%; font-size: 12px; border: 1px solid #ccc;">
    <span style="font-size: 18px; font-weight: bold; float: left; padding-top: 17px;padding-left: 15px;">
        <img src="../../Content/Images/Admin/product.png" />
        CHỨC NĂNG
    </span>
</div>
@using (Html.BeginForm())
{
    <table class="Conten_main_sanpham" cellpadding="0" style="text-shadow: #fff 0px 1px 0px;">
        <tr>
            <td colspan="2">@ViewBag.ThongBao</td>
        </tr>
        <tr class="row">
            <td class="box_title">Tên chức năng
            </td>
            <td class="box_object">
                <input type="hidden" name="txtID" id="txtID" class="input_text" style="width: 300px" value="@ViewBag.Id" />
                <input type="text" name="txtTen" id="txtTen" class="input_text" style="width: 300px" value="@ViewBag.Ten" />
            </td>
        </tr>
        <tr class="row">
            <td class="box_title">Mã
            </td>
            <td class="box_object">
                <input type="text" name="txtCode" id="txtCode" class="input_text" style="width: 300px" value="@ViewBag.Ma" />
                (vd: xoa_san_pham)
            </td>
        </tr>
        <tr class="row">
            <td class="box_title"></td>
            <td class="box_object">
                <input class="normal green button input" type="submit" value="Lưu" />

            </td>
        </tr>
    </table>
}
<br />
    <a href="#" class="normal blue button input btnThemMoi">Thêm mới</a>
    <script>
        $('.btnThemMoi').click(function () {
            $("#txtTen").val('');
            $("#txtCode").val('');
            $("#txtTen").focus();
            $("#txtID").val('');
        });
    </script>
    <a href="~/admin" class="normal black button input">Thoát</a>
    <br />
    <br />
<table cellspacing="0" rules="rows" class="rows" border="1" style="width: 100%; border-collapse: collapse;">
        <tr class="item_title" style="color: White; background-color: #CCCCCC; font-family: Tahoma; font-size: 12px; font-weight: bold; height: 30px;">
            <th>ID</th>
            <th>Tên</th>
            <th>Mã</th>
            <th></th>
        </tr>
    @foreach (var chucnang in ViewBag.OnePage)
    {
        <tr class="item_row" style="border-color: #F0F0F0; border-style: Solid; height: 40px;">
            <td class="item_float">
                <label>
                    <input type="hidden" value="@chucnang.IdChucNang" id="Id"/>
                    @chucnang.IdChucNang
                </label>
            </td>
            <td class="item_float">
                <label>
                    <input type="hidden" value="@chucnang.TenChucNang" id="Ten"/>
                    @chucnang.TenChucNang
                </label>
            </td>
            <td class="item_float">
                <label>
                    <input type="hidden" value="@chucnang.MaChucNang" id="Code"/>
                    @chucnang.MaChucNang
                </label>
            </td>
            <td class="td-actions">
            <div class="hidden-phone visible-desktop action-buttons">
                <a href="#" class="small blue button btnSua">Sửa</a>
                <script>
                    $('.btnSua').click(function () {
                        var tr = $(this).parents('tr:first');
                        var ten = tr.find("#Ten").val();
                        var Id = tr.find("#Id").val();
                        var Code = tr.find("#Code").val();
                        $("#txtTen").val(ten);
                        $("#txtTen").focus();
                        $("#txtID").val(Id);
                        $("#txtCode").val(Code);
                    });
                </script>
            </div>
        </td>
         </tr>
    }
</table>

@Html.PagedListPager((IPagedList)ViewBag.OnePage,page=>Url.Action("ChucNang",new{page}),PagedListRenderOptions.OnlyShowFivePagesAtATime)
